package common

// 告警状态 (适用于设备告警和参数告警)
type EAlarmStatus int

const (
	EAlarmStatusNormal   EAlarmStatus = 0 // 正常
	EAlarmStatusWarning  EAlarmStatus = 1 // 警告
	EAlarmStatusCritical EAlarmStatus = 2 // 严重
)

type EEnAbleState int

const (
	Enable  EEnAbleState = 0
	Disable EEnAbleState = 1
)

// 设备历史触发类型
type EHistoryTriggerType int

const (
	EHistoryTriggerScheduled EHistoryTriggerType = 0 // 定时触发
	EHistoryTriggerEvent     EHistoryTriggerType = 1 // 事件触发
)

// 参数值类型
type EArgValueType int

const (
	EArgTypeShort  EArgValueType = 0 // 整数
	EArgTypeInt    EArgValueType = 1 // 整数
	EArgTypeFloat  EArgValueType = 2 // 浮点数
	EArgTypeString EArgValueType = 3 // 字符串
	EArgTypeBool   EArgValueType = 4 // 布尔值
	EArgTypeBytes  EArgValueType = 5 // 字节数组
)

// 参数类型
type EArgType int

const (
	EArgTypeDev     EArgType = 0 // 设备参数
	EArgTypeDefault EArgType = 1 // 默认值参数
	EArgTypeCustum  EArgType = 2 // 自定义参数
)

// 参数推送类型
type EArgPushType int

const (
	EPushNever           EArgPushType = 0 // 不推送
	EPushOnChange        EArgPushType = 1 // 变化时推送
	EPushOnInterval      EArgPushType = 2 // 定时推送
	EPushOnChangeAndTime EArgPushType = 3 // 变化+定时推送
)

// 参数写权限
type EArgWriteEnable int

const (
	EArgWriteDisabled EArgWriteEnable = 0 // 禁止写入
	EArgWriteEnabled  EArgWriteEnable = 1 // 允许写入
)

// 字节序
type EByteOrder int

const (
	EByteOrderLittleEndian EByteOrder = 0 // 小端序
	EByteOrderBigEndian    EByteOrder = 1 // 大端序
)

// 数据质量
type EDataQuality int

const (
	EDataQualityGood   EDataQuality = 0 // 好
	EDataQualityNormal EDataQuality = 1 // 一般
	EDataQualityBad    EDataQuality = 2 // 差
)

// 数据来源
type EDataSource int

const (
	EDataSourceAcquisition EDataSource = 0 // 采集
	EDataSourceManual      EDataSource = 1 // 手动
	EDataSourceCalculation EDataSource = 2 // 计算
)

// 串口校验位
type ESerialParity string

const (
	ESerialParityNone ESerialParity = "None" // 无校验
	ESerialParityOdd  ESerialParity = "Even" // 奇校验
	ESerialParityEven ESerialParity = "Add"  // 偶校验
)

// 采集协议类型
type EProtocolType int

const (
	EAcquisitionProtocolModbus     EProtocolType = 0
	EAcquisitionProtocolOPCUA      EProtocolType = 1
	EAcquisitionProtocolProfinet   EProtocolType = 2
	EAcquisitionProtocolEthernetIP EProtocolType = 3
	EAcquisitionProtocolCAN        EProtocolType = 4
)

// 推送传输类型
type ETransportType string

const (
	ETransportTypeMQTT      ETransportType = "MQTT"
	ETransportTypeKafka     ETransportType = "Kafka"
	ETransportTypeHTTP      ETransportType = "HTTP"
	ETransportTypeWebSocket ETransportType = "WebSocket"
	ETransportTypeGRPC      ETransportType = "gRPC"
)

// 数据格式
type EDataFormat string

const (
	EDataFormatJSON   EDataFormat = "json"
	EDataFormatXML    EDataFormat = "xml"
	EDataFormatBytes  EDataFormat = "binary"
	EDataFormatCSV    EDataFormat = "csv"
	EDataFormatCustom EDataFormat = "custom"
)

// 告警类型
type EAlarmType int

const (
	EAlarmTypeDevice    EAlarmType = 0 // 设备告警
	EAlarmTypeParameter EAlarmType = 1 // 参数告警
)

// 告警等级
type EAlarmLevel int

const (
	EAlarmLevelInfo      EAlarmLevel = 0 // 提示
	EAlarmLevelWarning   EAlarmLevel = 1 // 警告
	EAlarmLevelCritical  EAlarmLevel = 2 // 严重
	EAlarmLevelEmergency EAlarmLevel = 3 // 紧急
)

// 告警恢复方式
type ERecoveryWay int

const (
	ERecoveryWayAuto   ERecoveryWay = 0 // 自动恢复
	ERecoveryWayManual ERecoveryWay = 1 // 手动恢复
)

// 设备权限级别
type EPermissionLevel int

const (
	EPermissionLevelReadOnly  EPermissionLevel = 1 // 只读
	EPermissionLevelReadWrite EPermissionLevel = 2 // 读写
	EPermissionLevelAdmin     EPermissionLevel = 3 // 管理
)

// 操作结果
type EOperationResult int

const (
	EOperationResultFailure EOperationResult = 0 // 失败
	EOperationResultSuccess EOperationResult = 1 // 成功
)

// Modbus 寄存器类型
type EModbusRegisterType int

const (
	EModbusRegisterCoil          EModbusRegisterType = 0 // 线圈（可读可写，位）
	EModbusRegisterDiscreteInput EModbusRegisterType = 1 // 离散输入（只读，位）
	EModbusRegisterInputRegister EModbusRegisterType = 2 // 输入寄存器（只读，16位）
	EModbusRegisterHolding       EModbusRegisterType = 3 // 保持寄存器（可读可写，16位）
)

// Modbus 常用功能码
type EModbusFunctionCode int

const (
	EModbusFCReadCoils            EModbusFunctionCode = 1  // 读线圈
	EModbusFCReadDiscreteInputs   EModbusFunctionCode = 2  // 读离散输入
	EModbusFCReadHoldingRegisters EModbusFunctionCode = 3  // 读保持寄存器
	EModbusFCReadInputRegisters   EModbusFunctionCode = 4  // 读输入寄存器
	EModbusFCWriteSingleCoil      EModbusFunctionCode = 5  // 写单个线圈
	EModbusFCWriteSingleRegister  EModbusFunctionCode = 6  // 写单个保持寄存器
	EModbusFCWriteMultipleCoils   EModbusFunctionCode = 15 // 写多个线圈
	EModbusFCWriteMultipleRegs    EModbusFunctionCode = 16 // 写多个保持寄存器
	EModbusFCMaskWriteRegister    EModbusFunctionCode = 22 // 掩码写寄存器
	EModbusFCReadWriteRegs        EModbusFunctionCode = 23 // 读写多个寄存器
)

type Topic string

// 使用字符串常量定义事件类型
const (
	// 系统核心事件
	SystemStart    Topic = "system_start"
	SystemShutdown Topic = "system_shutdown"

	// 监控事件
	MonitorPointChange Topic = "MonitorPointChange"
	MonitorPeriod      Topic = "MonitorPeriod"
)
